/*
	Copyright (C) 2010 2011 Rémi Thebault

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GANTTCYCLE_H
#define GANTTCYCLE_H


#include <procycle/cycle.h>

#include "globals.h"
#include "ganttmtask.h"

class GanttLink;

class GanttCycle : public GanttMTask
{
public:
	GanttCycle(ProCycle* app, PC::Cycle* cycle);
	virtual ~GanttCycle() {
	}

	QRectF boundingRect() const;

	virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/);


	virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);

	virtual void replaceChildren();

	PC::Cycle* cycle() {
		return static_cast<PC::Cycle*>(task());
	}

	void addLink(GanttLink* gl);
	void removeLink(GanttLink* gl);
	GanttLink* findGLink(PC::Link* link);

	virtual void resetTask(PC::Task *task);

	QList<GanttLink*> inGLinksForGTask(GanttTask* gt);
	QList<GanttLink*> outGLinksForGTask(GanttTask* gt);

	virtual void setCycleProp(PC::Cycle::Property p, const QVariant& value);
	virtual void editModeChanged();

public slots:
	void processExpansionChange(PC::Task* task);

	void processScheduled();

private:


	QList<GanttLink*>	m_glinks;
};

#endif // GANTTCYCLE_H
